package cn.zhuangcloud.newversion.login;

import cn.zhuangcloud.newversion.common.enums.RetCodeEnum;
import cn.zhuangcloud.newversion.common.enums.en.RetMessageEnum;
import com.jfinal.core.Controller;
import com.jfinal.kit.Ret;
import com.jfinal.validate.Validator;

public class LoginValidator extends Validator {
    @Override
    protected void validate(Controller c) {
        validateRegex("username","^[A-Z0-9a-z]{4,12}$","code",RetCodeEnum.FORMAT.toString());
    }

    @Override
    protected void handleError(Controller c) {
        c.renderJson(Ret.by("status",false).set("code", RetCodeEnum.FORMAT).set("message",  RetMessageEnum.FORMAT));
    }
}
